from urllib.request import urlopen
from urllib.error import HTTPError, URLError

if __name__ == '__main__':
    # url = "https://httpbin.org/get"
    url = "http://www.baidu.com/net"

    try:

        resp = urlopen(url=url, timeout=1)
        content = resp.read()
        result = content.decode("utf-8")
        print(result)

    except HTTPError as http_error:
        print(http_error)
    except URLError as url_error:
        print(url_error)
    except Exception as error:
        print(error)
